<?php
include 'common/autoload.php';
include 'common/header.html';
include 'common/left.html';
include 'class/Member.php';//会员类，获取登陆会员的相关信息
$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
$mem = new Member($s, $_SESSION['memberID']);
$flag = false;
$post_url = 'proedittest.php?type=f';
// $post_url = 'prod_edits_dt.php?type=f';

$prods[1]=$mem->salePros();// 获取门票
$lid=3079;
$prod[2]=$mem->salePros($lid);
print_r($prod);
//print_r($prods[1]);
$_SESSION['prods']=$prods[1];
//print_r($_SESSION['prods']);

$tmp = $save = array();
$sortType='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$fids = array();//分销商id
for($i=0;$i<strlen($sortType);$i++){
	foreach($prods[1] as $k=>$val){
		if($val['p_type']=='F' || $val['p_type']=='B') continue;
		if($sortType[$i]==$val['py']){
			$tmp['p_type'] = $val['p_type'];
			$tmp['sapply_did'] = $val['sapply_did'];//供应商id
			$tmp['title'] = $val['title'];
			$tmp['py'] = $val['py'];
			$tmp['lid'] = $val['lid'];
			$fids[$val['sapply_did']]=$val['sapply_did'];
			$save[$val['lid'].'_'.$val['sapply_did']]=$tmp;
			unset($prods[1][$k]);
		}
	}
}
$prods[1]=$save;//获得景区详情
//print_r($prods[1]);
if(count($fids)){
	$sql="select id,dname from pft_member where id in (".implode(',',$fids).")";
	$GLOBALS['le']->query($sql);
	$dname = array();
	while($list = $GLOBALS['le']->fetch_assoc()){
		$dname[$list['id']] = $list['dname'];
	}
}
?>
<link rel="stylesheet" href="css/aliceui.min.css">
<link rel="stylesheet" href="css/resetui.css">
<link rel="stylesheet" href="css/prod_package.css?v=1010">
<link rel="stylesheet" href="css/prod_package_f.css?v=1010">
<div class="wrap">
    <div class="left">
	<div class="input-wrap">
					 <input type="text" class="searchtext" name="user_filter" id="user_filter">
					<span class="qcha">快速查找:</span>
			 	</div>
        <div id="prod_result" class="list">
            <?foreach($prods as $key=>$prod){?>
            <ul id="prod_r<?=$key?>" class="prod_list">
                <?foreach($prod as $p){?>
                    <li class="<?=$p['p_type']?>">
                        <label>
                            <input type="checkbox" class="chkbox" data-title="<?=$p['title']?>" data-aid="<?=$p['sapply_did']?>" value="<?=$p['lid']?>" name="p1[]"><?=$p['py']?>-<?=$p['title']?>【<?=$dname[$p['sapply_did']]?>】
                        </label>
                    </li>
                <?}?>
            </ul>
            <?}?>
        </div>
        <div id="tickt_result"></div>
        <div class="btn">
            <button type="button" class="ui-button ui-button-lorange" id="submit">下一步</button>
        </div>
    </div>
    <div class="right">
        <h2>您选择的产品</h2>
        <ul class="selected" id="selected"></ul>
    </div>
</div>
<script type="text/javascript">
(function(){
	$("ul.tabHead").on('click', 'li', function(){
		var wrap = $(this).attr('data-wrap'),c='buyers';
		$(this).addClass('current')
			.siblings('li.current')
			.removeClass('current');
		if($("#buyers_user_"+wrap).length) {
			$("#buyers_user_"+wrap).show().siblings('ul').hide();
		}
	});
	$(".list").on('click','input:radio', function(){
		html = $(this).attr("data-name")+"["+$(this).siblings().html()+"]";
		$("#applyer").text(html).removeClass('nochoice');
		$("input[name='apply_did']").val($(this).val());
		if($("button#sub").hasClass('ui-button-sdisable')){
			$("button#sub").removeClass('ui-button-sdisable')
				.addClass('ui-button-sorange')
				.removeAttr('disabled');
		}
		$(".pmid").val($(this).val());
		
	});
	$("input#user_filter").on('keyup',function(){
		var user_list = $("div.list:visible").find('li'),
			len = user_list.length,
			i= 0,
			searchTxt = $(this).val();
		if(searchTxt=='') {
			return;
		}
		if(!isNaN(searchTxt) && searchTxt.length<6) {
			return;
		}
		for(;i<len;i++) {
			if(user_list[i].innerText.indexOf(searchTxt)>-1) {
				//console.log(user_list[i].innerText);
				$(user_list[i]).css('background-color','#ffff66');
				var a = $(user_list[i]).parents('ul.user_list').attr('data-alpha');
				$("ul.tabHead").find("li[data-wrap='"+a+"'").trigger("click");
//                $("li[data-wrap='"+a+"'").trigger('click');
			} else {
				$(user_list[i]).css('background-color','#fff');
			}
		}
	});
	 
})();

</script>
<form id="hideFrm" action="<?=$post_url;?>" method="post">
    <input type="hidden" name="package_data"/>
</form>
<script src="js/json2.js"></script>
<script src='js/prod_package.js'></script>
<?include('common/footer.html');?>